package com.basic.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

@Component
public class RedisTool {

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    public String get(String key)
    {
        ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
        return ops.get(key);
    }

    public void set(String key, String value)
    {
        ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
        ops.set(key, value);

    }

    public void set(String key, String value, Long ttl)
    {
        ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
        ops.set(key, value, ttl);
    }
}
